﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace XCT.Class
{
    class clsBTP
    {


        #region "Attributes"

        private int iD_L;
        private int mapnhap_id;
        private int maChietTinhML;
        private int iThem;
        private string soLSX;
        private string tuanKh;
        private string maSP;
        private DateTime ngayTH;
        private string maChungLoai_Mousse;
        private string maMau_Mousse;
        private int maHoaVan_Mousse;
        private int maChiTiet_Mousse;
        private int dvtID;
        private string maCD;
        private float doLy;
        private float dinhMuc;
        private string quiCach;
        private int iSoLop;
        private string sDienGiai;
        private string maMau_SP;
        private string doShore;       
        private float sLKH;
        private float sL_Nhap_Ca1;
        private float sL_Nhap_Ca2;
        private float sL_Nhap_Ca3;
        private float tong_SL_Nhap;
        private float fSL_CanTH;
        private float fSL_ConLai;
        private float fSL_LuyKe;
        private string ghiChu;
        private string userUpdate;
        private DateTime dateUpdate;
        private string sCLLH;
        #endregion

        #region "Properties"

        public int MaChietTinhML
        {
            get { return maChietTinhML; }
            set { maChietTinhML = value; }
        }

        public int Them
        {
            get { return iThem; }
            set { iThem = value; }
        }
        public int ID_L
        {
            get { return iD_L; }
            set { iD_L = value; }
        }
        public int PNhap_BTP_LID
        {
            get { return mapnhap_id; }
            set { mapnhap_id = value; }
        }

        public string SoLSX
        {
            get { return soLSX; }
            set { soLSX = value; }
        }

        public string TuanKH
        {
            get { return tuanKh; }
            set { tuanKh = value; }
        }
        public string MaSP
        {
            get { return maSP; }
            set { maSP = value; }
        }

        public DateTime NgayTH
        {
            get { return ngayTH; }
            set { ngayTH = value; }
        }

        public string MaChungLoai_Mousse
        {
            get { return maChungLoai_Mousse; }
            set { maChungLoai_Mousse = value; }
        }

        public string DienGiai
        {
            get { return sDienGiai; }
            set { sDienGiai = value; }
        }

        public string MaMau_Mousse
        {
            get { return maMau_Mousse; }
            set { maMau_Mousse = value; }
        }

        public int MaHoaVan_Mousse
        {
            get { return maHoaVan_Mousse; }
            set { maHoaVan_Mousse = value; }
        }

        public int MaChiTiet_Mousse
        {
            get { return maChiTiet_Mousse; }
            set { maChiTiet_Mousse = value; }
        }

        public int DvtID
        {
            get { return dvtID; }
            set { dvtID = value; }
        }

        public string MaCD
        {
            get { return maCD; }
            set { maCD = value; }
        }

        public float DoLy
        {
            get { return doLy; }
            set { doLy = value; }
        }

        public float DinhMuc
        {
            get { return dinhMuc; }
            set { dinhMuc = value; }
        }

        public string QuiCach
        {
            get { return quiCach; }
            set { quiCach = value; }
        }

        public int SoLop
        {
            get { return iSoLop; }
            set { iSoLop = value; }
        }

        public string MaMau_SP
        {
            get { return maMau_SP; }
            set { maMau_SP = value; }
        }

        public string DoShore
        {
            get { return doShore; }
            set { doShore = value; }
        }

        public float SLKH
        {
            get { return sLKH; }
            set { sLKH = value; }
        }
        public float SL_CanTH
        {
            get { return fSL_CanTH; }
            set { fSL_CanTH = value; }
        }

        public float SL_ConLai
        {
            get { return fSL_ConLai; }
            set { fSL_ConLai = value; }
        }

        public float SL_LuyKe
        {
            get { return fSL_LuyKe; }
            set { fSL_LuyKe = value; }
        }

        public float SL_Nhap_Ca1
        {
            get { return sL_Nhap_Ca1; }
            set { sL_Nhap_Ca1 = value; }
        }

        public float SL_Nhap_Ca2
        {
            get { return sL_Nhap_Ca2; }
            set { sL_Nhap_Ca2 = value; }
        }

        public float SL_Nhap_Ca3
        {
            get { return sL_Nhap_Ca3; }
            set { sL_Nhap_Ca3 = value; }
        }

        public float Tong_SL_Nhap
        {
            get { return tong_SL_Nhap; }
            set { tong_SL_Nhap = value; }
        }

        public string GhiChu
        {
            get { return ghiChu; }
            set { ghiChu = value; }
        }

        public string CLLH
        {
            get { return sCLLH; }
            set { sCLLH = value; }
        }

        public string UserUpdate
        {
            get { return userUpdate; }
            set { userUpdate = value; }
        }


        public DateTime DateUpdate
        {
            get { return dateUpdate; }
            set { dateUpdate = value; }
        }
        #endregion





        public DataTable KiemTraNgayNhap(string SQL)
        {

            DataProvider dp = new DataProvider();
            return dp.ftblDocDuLieuSQL(SQL);    
        }

        public DataTable GetSLKH(string SQL)
        {
            DataProvider dp = new DataProvider();
            return dp.ftblDocDuLieuSQL(SQL);    
        }

        


        // doc chung loai mousse
        public DataSet DocChungLoaiMousse_BTP(string Solsx)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = Solsx;

            return dp.fdtsDocDuLieuSP("sp_ChungLoai_BTP", arrPara);
        }
        
        // doc cong doan khi chon LSX
        public DataSet DocCongDoanLSX_BPT(string Solsx)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = Solsx;

            return dp.fdtsDocDuLieuSP("sp_CongDoanLSX_BTP", arrPara);
        }

        // doc cong doan khi chon Chung Loai
        public DataSet DocCongDoanChungLoai_BPT(string Solsx, string ChungLoai)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[2];
            arrPara[0] = new SqlParameter("@pSoLSX", SqlDbType.VarChar);
            arrPara[0].Value = Solsx;
            arrPara[1] = new SqlParameter("@pChungLoai", SqlDbType.VarChar);
            arrPara[1].Value = ChungLoai;

            return dp.fdtsDocDuLieuSP("sp_CongDoanChungLoai_BTP", arrPara);
        }

        // Đọc LSX theo TuanKH
        public DataSet DocLSXTheoTuanKH(string TuanKH)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@pTuanKH", SqlDbType.VarChar);
            arrPara[0].Value = TuanKH;

            return dp.fdtsDocDuLieuSP("proc_DocLSXTheoTuanKH", arrPara);
        }



        // KiemTraDongBo
        public DataSet KiemTraDongBo(string SoLSX)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;

            return dp.fdtsDocDuLieuSP("proc_DongBo_BTP", arrPara);
        } 
        
        // Đọc LSX theo LSX
        public DataSet DocLSXTheoLSX(string LSX)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSX", SqlDbType.VarChar);
            arrPara[0].Value = LSX;

            return dp.fdtsDocDuLieuSP("proc_DocLSXTheoLSX", arrPara);
        }

        // Đọc BTP theo LSX
        public DataSet GetBTPTheoLSX(string SoLSX, string NgayNhap, int Them)
        {
            DataProvider dp = new DataProvider();

            SqlParameter[] arrPara = new SqlParameter[3];
            arrPara[0] = new SqlParameter("@SoLSX", SqlDbType.VarChar);
            arrPara[0].Value = SoLSX;
            arrPara[1] = new SqlParameter("@NgayNhap", SqlDbType.DateTime);
            arrPara[1].Value = NgayNhap;
            arrPara[2] = new SqlParameter("@Them", SqlDbType.Int);
            arrPara[2].Value = Them;

            return dp.fdtsDocDuLieuSP("sp_GetBTPTheoLSX", arrPara);
        }

        // Sua kinh nghiem hoat dong
        public Boolean LuuBTP()
        {
            SqlParameter[] arrPara = new SqlParameter[26];
            
            arrPara[0] = new SqlParameter("@PNhap_BTP_LID", SqlDbType.Int);
            arrPara[0].Value = PNhap_BTP_LID;

            arrPara[1] = new SqlParameter("@MaChietTinhML", SqlDbType.Int);
            arrPara[1].Value = MaChietTinhML;

            arrPara[2] = new SqlParameter("@SoLSX", SqlDbType.VarChar);
            arrPara[2].Value = SoLSX;
            
            arrPara[3] = new SqlParameter("@NgayNhap", SqlDbType.DateTime);
            arrPara[3].Value = NgayTH;

            arrPara[4] = new SqlParameter("@MaSP", SqlDbType.VarChar);
            arrPara[4].Value = MaSP;

            arrPara[5] = new SqlParameter("@MaChungLoai_Mousse", SqlDbType.VarChar);
            arrPara[5].Value = MaChungLoai_Mousse;
            
            arrPara[6] = new SqlParameter("@MaMau_Mousse", SqlDbType.VarChar);
            arrPara[6].Value = MaMau_Mousse;

            arrPara[7] = new SqlParameter("@MaHoaVan_Mousse", SqlDbType.Int);
            arrPara[7].Value = MaHoaVan_Mousse;
            
            arrPara[8] = new SqlParameter("@MaChiTietMousse", SqlDbType.Int);
            arrPara[8].Value = MaChiTiet_Mousse;
                        
            arrPara[9] = new SqlParameter("@DVTID", SqlDbType.Int);
            arrPara[9].Value = DvtID;

            arrPara[10] = new SqlParameter("@MaCD", SqlDbType.VarChar);
            arrPara[10].Value = MaCD;

            arrPara[11] = new SqlParameter("@QuiCach", SqlDbType.VarChar);
            arrPara[11].Value = QuiCach;            
            
            arrPara[12] = new SqlParameter("@SLKH", SqlDbType.Float);
            arrPara[12].Value = SLKH;

            arrPara[13] = new SqlParameter("@Ca1", SqlDbType.Float);
            arrPara[13].Value = SL_Nhap_Ca1;

            arrPara[14] = new SqlParameter("@Ca2", SqlDbType.Float);
            arrPara[14].Value = SL_Nhap_Ca2;

            arrPara[15] = new SqlParameter("@Ca3", SqlDbType.Float);
            arrPara[15].Value = SL_Nhap_Ca3;

            arrPara[16] = new SqlParameter("@SL_Nhap", SqlDbType.Float);
            arrPara[16].Value = Tong_SL_Nhap;
            
            arrPara[17] = new SqlParameter("@SL_ConLai", SqlDbType.Float);
            arrPara[17].Value = SL_ConLai;
            
            arrPara[18] = new SqlParameter("@GhiChu", SqlDbType.VarChar);
            arrPara[18].Value = GhiChu;

            arrPara[19] = new SqlParameter("@SL_CanTH", SqlDbType.Float);
            arrPara[19].Value = SL_CanTH;

            arrPara[20] = new SqlParameter("@TuanKH", SqlDbType.VarChar);
            arrPara[20].Value = TuanKH;

            arrPara[21] = new SqlParameter("@UserUpdate", SqlDbType.VarChar);
            arrPara[21].Value = UserUpdate;

            arrPara[22] = new SqlParameter("@DateUpdate", SqlDbType.DateTime);
            arrPara[22].Value = DateUpdate;

            arrPara[23] = new SqlParameter("@SL_LuyKe", SqlDbType.Float);
            arrPara[23].Value = SL_LuyKe;

            arrPara[24] = new SqlParameter("@DoLy", SqlDbType.Float);
            arrPara[24].Value = DoLy;
            
            arrPara[25] = new SqlParameter("@SoLop", SqlDbType.Int);
            arrPara[25].Value = SoLop;

            DataProvider dp = new DataProvider();
            return dp.fBolThucThiSP("proc_LuuBTP", arrPara);
        }



    }
}
